const reverseNumber = function (number) {
    var str = String(number);
    if(str.length>9){
        return 0
    }
    if(str.charAt(0) == "-"){
        var str_r = String(number).substr(1,str.length);
        return parseInt("-"+str.split("").reverse().join(""));
    }

    return parseInt(str.split("").reverse().join(""))
};
console.log(reverseNumber(-123));

const reverseNumber2 = (num) => {
    if(num >=0){
        const numStr = String(num);
        return Number(numStr.split('').reverse().join(''))
    } else {
        const numStr = String(num);
        return -numStr.slice(1).split('').reverse().join('')
    }
};
console.log(reverseNumber2(123));
console.log(reverseNumber2(-123));

